const {bannerHttp,handleStr,handleStar,getReadHttp} = require("../../utils/http")
Page({
    data:{
        banner:[],
        read:[]
    },
    onLoad(){
        getReadHttp().then(res=>{
            // console.log(res.data);
            this.handleReadData(res)
        })
        bannerHttp().then(res=>{
            var banner = []
            res.data.res.forEach(item=>{
                var {imgUrl} = item;
                banner.push({
                    imgUrl
                })
            })
            // console.log(banner);
            this.setData({
                banner,
            })
        })
    },
    handleReadData(res){
        var read= []
                res.data.forEach(item=>{
                    var {_id,pic,title,rating} =item;
                    read.push({
                        _id,
                        pic,
                        title:handleStr(title),
                        rating,
                        star:handleStar(rating)
                    })
                })
                this.setData({
                    read,
                })
    },
    onClick(event){
        var {aid} = event.currentTarget.dataset;
        wx.navigateTo({
          url: `/pages/movieDetail/movieDetatil?id=${aid}`,
        })
    }
})
